using System;
using System.Collections.Generic;

namespace ProgrammingLanguageNr1
{
	public class MemorySpace
	{
		public MemorySpace (string name)
		{
			m_name = name;
		}
		
		public void setValue(string name, ReturnValue val) {
			//Console.WriteLine("Set a value with name " + name + " and type " + val.getReturnType());
			if(m_valuesForStrings.ContainsKey(name)) {
				m_valuesForStrings[name] = val;
			} else {
				m_valuesForStrings.Add(name, val);
			}
		}
		
		public ReturnValue getValue(string name) {
			//Console.WriteLine("Fetching value with name " + name);
			if(!m_valuesForStrings.ContainsKey(name)) {
				throw new InvalidOperationException("Can't find value with name " + name + " in memory space " + m_name);
			}
			
			return m_valuesForStrings[name];
		}
		
		public string getName() {
			return m_name;
		}
		
		string m_name;
		Dictionary<string, ReturnValue> m_valuesForStrings = new Dictionary<string, ReturnValue>();
	}
}

